#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using webapp4U.DAL;
#endregion


namespace webapp4U.BOL
{
	 public class ArticleCategory
	 {
         #region Member Variables

         private Int32 _cateID;

         private String _appKey;

         private String _cateName;

         private String _cateName_en;

         private String _cateDesc;

         private String _imageUrl;

         private Int32 _cateOrder;

         private Int32 _parentID;

         #endregion



         #region Public Properties

         public Int32 CateID
         {
             get { return _cateID; }
             set { _cateID = value; }
         }

         public String AppKey
         {
             get { return _appKey; }
             set { _appKey = value; }
         }

         public String CateName
         {
             get { return _cateName; }
             set { _cateName = value; }
         }

         public String CateName_en
         {
             get { return _cateName_en; }
             set { _cateName_en = value; }
         }

         public String CateDesc
         {
             get { return _cateDesc; }
             set { _cateDesc = value; }
         }

         public String ImageUrl
         {
             get { return _imageUrl; }
             set { _imageUrl = value; }
         }

         public Int32 CateOrder
         {
             get { return _cateOrder; }
             set { _cateOrder = value; }
         }

         public Int32 ParentID
         {
             get { return _parentID; }
             set { _parentID = value; }
         }

         #endregion


	     #region public static Methods

         // lay nhung loai cong viec hien thi o trang chu
         public static List<ArticleCategory> GetArticleCategoryHomePageByParentID(Int32 ParentID)
         {
             ArticleCategoryDAL db = new ArticleCategoryDAL();
             return db.GetArticleCategoryHomePageByParentID(ParentID);
         }


	     public static int Insert(ArticleCategory obj)
	     {
		     ArticleCategoryDAL db = new ArticleCategoryDAL();
		     return db.Insert(obj);
	     }

	     public static bool Update(ArticleCategory obj)
	     {
		     ArticleCategoryDAL db = new ArticleCategoryDAL();
		     return db.Update(obj);
	     }

	     public static bool Delete(Int32 CateID)
	     {
             if (CateID == Globals.ConvertToInt32(eCategory.Dichvu))
                 return false;

             if (CateID == Globals.ConvertToInt32(eCategory.News))
                 return false;

             if (CateID == Globals.ConvertToInt32(eCategory.RootCategory))
                 return false;

             //if (CateID == Globals.ConvertToInt32(eCategory.TuvanTuyendung))
             //    return false;
		     ArticleCategoryDAL db = new ArticleCategoryDAL();
		     return db.Delete(CateID); 
	     }

	     public static ArticleCategory GetArticleCategoryByID(Int32 CateID)
	     {
		     ArticleCategoryDAL db = new ArticleCategoryDAL();
		     return db.GetArticleCategoryByID(CateID);
	     }

         public static string GetCateNameByCateID(Int32 CateID)
         {
             try
             {
                 ArticleCategory obj = GetArticleCategoryByID(CateID);
                 return (Globals.LangVietNam()) ? obj.CateName : obj.CateName_en;
             }
             catch
             {
                 return "";
             }
         }


	     //Get All ArticleCategory
	     public static List<ArticleCategory> GetAllArticleCategory(int PageIndex, int PageSize)
	     {
		     ArticleCategoryDAL db = new ArticleCategoryDAL();
		     return db.GetAllArticleCategory(PageIndex, PageSize);
	     }

	     // Get Count All records of Table  ArticleCategory
	     public static int GetCountArticleCategory()
	     {
		     ArticleCategoryDAL db = new ArticleCategoryDAL();
		     return db.GetCountArticleCategory();
	     }


         public static Int32 GetAutoCateID()
         {
             ArticleCategoryDAL db = new ArticleCategoryDAL();
             return db.GetAutoCateID();
         }


         public static List<ArticleCategory> GetArticleCategoryByParentID(Int32 ParentID)
         {
             ArticleCategoryDAL db = new ArticleCategoryDAL();
             return db.GetArticleCategoryByParentID(ParentID);
         }

	 #endregion
	 }
}
